package vmcs.entity;

import vmcs.observer.StoreItemChangeManager;

// Copyright 1997 ISS.
// The contents contained in this document may not be reproduced in any
// form or by any means, without the written permission of ISS, other
// than for the purpose for which it has been supplied.
//
// Author: Olivo Miotto
//

public abstract class StoreItem {

    private StoreObject	content;
    protected int		quantity;
    protected StoreItem nextItem = null;
    
    public StoreItem (StoreObject content, int quantity) {
        this.content = content;
        this.quantity = quantity;
    }

    public StoreObject getContent () {
        return content;
    }

    public void setContent(StoreObject ct){
      content = ct;
    }

    public abstract void setQuantity (int quantity);

    public int getQuantity () {
        return quantity;
    }

    public void store () {
        // OBSERVER IMPL BEGIN
        
        // quantity++;
    	// change to use setQuantity so that notify can be triggered
    	setQuantity( quantity + 1 );

        // OBSERVER IMPL END
    }

    //Chain of responsibility
    public void setNext( StoreItem next){
        this.nextItem = next;
    }
    // OBSERVER IMPL BEGIN
    
    protected abstract StoreItemChangeManager getStoreItemChangeManager();

    // OBSERVER IMPL END
    
}

